Security News
RubyGems.org Adds New Maintainer Role
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
create-require
Advanced tools
The create-require npm package is designed to dynamically create a `require` function at a given path. This is particularly useful in scenarios where you need to resolve modules or require files relative to a specific directory, rather than the current working directory of the process. It can be used to simulate the behavior of Node.js's `require` in different contexts or to dynamically load modules from various locations in a filesystem.
Creating a custom require function for a specific directory
This feature allows you to create a new `require` function that resolves modules as if it was called from the specified directory. This is useful for loading modules from a directory different from the current script's directory.
const createRequire = require('create-require');
const myRequire = createRequire('/path/to/my/directory');
const myModule = myRequire('./myModule');
Similar to create-require, import-fresh allows you to require a module afresh, ensuring that it is re-evaluated. It's useful for testing and situations where you need to bypass Node's require cache. However, it doesn't allow specifying a directory for module resolution like create-require does.
Proxyquire is designed for overriding dependencies during testing. It allows you to create a custom `require` function that can return mock modules instead of the real ones. While it serves a different primary purpose (mocking for tests), it shares the concept of creating a custom require function with create-require.
create-require
Polyfill for Node.js module.createRequire
(<= v12.2.0)
yarn add create-require
npm install create-require
function createRequire (filename: string | URL): NodeRequire;
const createRequire = require('create-require')
const myRequire = createRequire('path/to/test.js')
const myModule = myRequire('./test-sibling-module')
FAQs
Polyfill for Node.js module.createRequire (<= v12.2.0)
The npm package create-require receives a total of 15,293,800 weekly downloads. As such, create-require popularity was classified as popular.
We found that create-require demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.
Security News
Research
Socket's threat research team has detected five malicious npm packages targeting Roblox developers, deploying malware to steal credentials and personal data.